package com.example.myapplication.ArrayAdapterInclude;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.example.myapplication.R;

public class IntentArrayInfoAdapter extends ArrayAdapter<String[]> {
  private String[][] infoData;
  public IntentArrayInfoAdapter(Context context, String[][] data) {
    super(context, R.layout.intent_text_info_layout);
    infoData=data;
  }

  @Override public int getCount() {
    return infoData.length;
  }

  @Nullable @Override public String[] getItem(int position) {
    return infoData[position];
  }

  @NonNull @Override
  public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    if (convertView == null) {
      convertView = LayoutInflater.from((getContext()))
          .inflate(R.layout.intent_text_info_layout, parent, false);
    }

    TextView textView = (TextView) convertView.findViewById(R.id.infoView);



    String str = ConvertString(getItem(position));
    textView.setText(str);
    return convertView;
  }

  private String ConvertString(String[] strings) {
    String str = getContext().getString(R.string.person_info,strings[0],strings[1]);

    return str;
  }
}
